package com.jt.www.admin.market.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jt.www.admin.market.service.MarketerInfoService;
import com.jt.www.admin.market.service.TeamService;
import com.jt.www.dao.mapper.market.MarketerInfoMapper;
import com.jt.www.dao.mapper.market.MarketerSyncTimeMapper;
import com.jt.www.dao.mapper.market.TeamMembersMapper;
import com.jt.www.domain.bo.MarketerDetailBO;
import com.jt.www.domain.enums.common.YesOrNoEnum;
import com.jt.www.domain.enums.pc.MarketerChannelCodeEnum;
import com.jt.www.domain.enums.pc.MarketerRoleEnum;
import com.jt.www.domain.enums.pc.MarketerStatusEnum;
import com.jt.www.domain.enums.pc.TeamMembersLevelEnum;
import com.jt.www.domain.po.MarketerInfoEntity;
import com.jt.www.domain.po.MarketerSyncTimeEntity;
import com.jt.www.domain.po.TeamMembersEntity;
import com.jt.www.domain.qo.BrokersInfoQO;
import com.jt.www.domain.qo.MarketerInfoQO;
import com.jt.www.domain.qo.MarketerUpdQO;
import com.jt.www.domain.vo.BrokersInfoVO;
import com.jt.www.domain.vo.CommissionTeamVO;
import com.jt.www.model.registerCustomer.vo.JtBranchInfoVo;
import com.jt.www.model.reps.GenericDataResponse;
import com.jt.www.model.reps.GenericListResponse;
import com.jt.www.model.reps.SaleResponseData;
import com.jt.www.remote.JtsaleappClient;
import com.jt.www.remote.UserClient;
import com.jt.www.util.DateUtils;
import com.jt.www.util.JsonUtil;
import com.jt.www.util.JsonUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.assertj.core.util.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.weekend.Weekend;
import tk.mybatis.mapper.weekend.WeekendCriteria;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class MarketerInfoServiceImpl implements MarketerInfoService {

    public static final Logger log = LoggerFactory.getLogger(MarketerInfoServiceImpl.class);
    private final static String SYS_CODE = "sys_edu_man";
    @Autowired
    UserClient userClient;
    @Autowired
    JtsaleappClient jtsaleappClient;
    @Autowired
    MarketerInfoMapper marketerInfoMapper;
    @Autowired
    MarketerSyncTimeMapper marketerSyncTimeMapper;
    @Autowired
    TeamMembersMapper teamMembersMapper;
    @Autowired
    private TeamService teamService;

    @Override
    public ResponseEntity queryMarketerById(String findCode, String id) {

        log.info("{} 根据ID查询营销人员信息 service 开始", findCode);

        Weekend<MarketerInfoEntity> weekend = Weekend.of(MarketerInfoEntity.class);
        WeekendCriteria<MarketerInfoEntity, Object> criteria = weekend.weekendCriteria();

        criteria.andEqualTo(MarketerInfoEntity::getId, id);
        criteria.andEqualTo(MarketerInfoEntity::getIsDeleted, false);

        List<MarketerInfoEntity> entities = marketerInfoMapper.selectByExample(weekend);

        if (entities != null && entities.size() > 0) {

            log.info("{} 根据ID查询营销人员信息 service 查询结果->{}", findCode, JsonUtil.object2Json(entities));

            return GenericDataResponse.okWithData(entities.get(0));
        } else {

            log.info("{} 根据ID查询营销人员信息 service 未查询到该营销人员 ID->{}", findCode, id);

            return GenericDataResponse.ok();
        }
    }

    @Override
    public ResponseEntity updateMarketer(String findCode, MarketerUpdQO marketerUpdQO) {

        log.info("{} 营销人员配置 service 开始", findCode);

        if (StringUtils.isBlank(marketerUpdQO.getId())) {
            return GenericDataResponse.ng("营销人员ID不能为空");
        }

        Weekend<MarketerInfoEntity> weekend = Weekend.of(MarketerInfoEntity.class);
        WeekendCriteria<MarketerInfoEntity, Object> criteria = weekend.weekendCriteria();

        criteria.andEqualTo(MarketerInfoEntity::getId, marketerUpdQO.getId());
        criteria.andEqualTo(MarketerInfoEntity::getIsDeleted, false);

        List<MarketerInfoEntity> entities = marketerInfoMapper.selectByExample(weekend);

        if (entities != null && entities.size() > 0) {

            log.info("{} 营销人员配置 service 根据ID查询营销人员信息 id->{},result->{}", findCode, marketerUpdQO.getId(), JsonUtil.object2Json(entities));

            MarketerInfoEntity entity = entities.get(0);

            entity.setRoleCode(marketerUpdQO.getRoleCode());
            entity.setRoleName(StringUtils.isNotBlank(marketerUpdQO.getRoleCode()) ? MarketerRoleEnum.getMsgByCode(marketerUpdQO.getRoleCode()) : "");
            entity.setLeaderCode(marketerUpdQO.getLeaderCode());
            entity.setLeaderName(marketerUpdQO.getLeaderName());
            entity.setBusinessScope(marketerUpdQO.getBusinessScope());

            //更新团队信息  只处理更新和新增，删除小队信息不在这块处理
            updateMarketerTeamFounder(findCode, marketerUpdQO, entity);

            marketerInfoMapper.updateByPrimaryKey(entity);
            log.info("{} 营销人员基本信息更新完成", findCode);

            log.info("{} 营销人员配置 service 更新完成", findCode);

            return GenericDataResponse.ok();
        } else {

            log.info("{} 营销人员配置 service 该营销人员不存在 id->{}", findCode, marketerUpdQO.getId());

            return GenericDataResponse.ng("该营销人员不存在");
        }
    }

    /**
     * 更新团队信息  只处理更新和新增，删除小队信息不在这块处理
     *
     * @param findCode
     * @param marketerUpdQO
     * @param marketerInfoEntity
     */
    private void updateMarketerTeamFounder(String findCode, MarketerUpdQO marketerUpdQO, MarketerInfoEntity marketerInfoEntity) {
        log.info("{} 检查并更新营销员团队信息开始。", findCode);
        if (null == marketerUpdQO.getTeamFounderId()) {
            return;
        }
        //现前团队信息
        List<CommissionTeamVO> teams = teamService.queryTeamByMarketerNo(marketerInfoEntity.getMarketerNo(), YesOrNoEnum.NO);

        TeamMembersEntity teamMembersEntity = new TeamMembersEntity();
        teamMembersEntity.setTeamFounderId(marketerUpdQO.getTeamFounderId());
        teamMembersEntity.setTeamId(marketerUpdQO.getTeamId());
        teamMembersEntity.setJoinTime(DateUtils.getCurrentTime());
        teamMembersEntity.setUpdateTime(DateUtils.getCurrentTime());
        //原来没有团队信息，但是这次配置有团队信息做插入
        if (CollectionUtils.isEmpty(teams)) {
            log.info("{} 原来没有团队信息，新团队ID{}，小队ID{}，插入小队成员信息表。", findCode, marketerUpdQO.getTeamFounderId(), marketerUpdQO.getTeamId());
            teamMembersEntity.setUserCode(marketerInfoEntity.getUserCode());
            teamMembersEntity.setMarketerNo(marketerInfoEntity.getMarketerNo());
            teamMembersEntity.setLevelCode(TeamMembersLevelEnum.LEVEL_1.getCode());
            teamMembersEntity.setLevelName(TeamMembersLevelEnum.LEVEL_1.getMsg());
            teamMembersEntity.setIsDeleted(false);
            teamMembersMapper.insertSelective(teamMembersEntity);
            //设置已经加入小队标识，地址传递，由上层去做更新
            marketerInfoEntity.setIsJoinTeam(true);
        } else if (CollectionUtils.isNotEmpty(teams) &&
                (!teams.get(0).getTeamFounderId().equals(marketerUpdQO.getTeamFounderId()) || !teams.get(0).getTeamId().equals(marketerUpdQO.getTeamId()))) {
            //原来有团队 新团队与原团队信息不一致 更新
            CommissionTeamVO commissionTeamVO = teams.get(0);
            log.info("{} 原来有创始人团队ID{}，小队ID{}，新团队ID{}，小队ID{}，团队信息不一致 更新小队成员信息表。",
                    findCode, teams.get(0).getTeamFounderId(), teams.get(0).getTeamId(), marketerUpdQO.getTeamFounderId(), marketerUpdQO.getTeamId());
            teamMembersEntity.setId(commissionTeamVO.getTeamMembersId());
            teamMembersMapper.updateByPrimaryKeySelective(teamMembersEntity);
        }
        log.info("{} 检查并更新营销员团队信息结束。", findCode);
    }

    @Override
    public List<MarketerInfoEntity> queryMarketersBy(String findCode, String roleCode) {

        log.info("{} 根据条件查询营销人员列表 service 开始", findCode);

        Weekend<MarketerInfoEntity> weekend = Weekend.of(MarketerInfoEntity.class);
        WeekendCriteria<MarketerInfoEntity, Object> criteria = weekend.weekendCriteria();

        criteria.andEqualTo(MarketerInfoEntity::getIsDeleted, false);
        criteria.andEqualTo(MarketerInfoEntity::getRoleCode, roleCode);

        weekend.setOrderByClause("create_time DESC");

        List<MarketerInfoEntity> entities = marketerInfoMapper.selectByExample(weekend);

        log.info("{} 根据条件查询营销人员列表 service 查询结果->{}", findCode, JsonUtil.object2Json(entities));

        return entities;
    }

    /**
     * 生成查询的weekend
     *
     * @param findCode
     * @param marketerInfoQO
     * @param validationPermissions 是否进行权限验证
     * @return
     */
    private Weekend<MarketerInfoEntity> createWeekend(String findCode, MarketerInfoQO marketerInfoQO, boolean validationPermissions) throws Exception {
        Weekend<MarketerInfoEntity> weekend = Weekend.of(MarketerInfoEntity.class);
        WeekendCriteria<MarketerInfoEntity, Object> criteria = weekend.weekendCriteria();

        criteria.andEqualTo(MarketerInfoEntity::getIsDeleted, false);

        if (validationPermissions) {
            // 权限设置
            ResponseEntity<GenericDataResponse<Map<String, Object>>> responseEntity = userClient.queryUserRoleAndAuthority(marketerInfoQO.getUserCode(), SYS_CODE);
            LinkedHashMap<String, String> map = (LinkedHashMap) responseEntity.getBody().getData().get("dataPopedom");
            String jtBranchs = map.get("jtBranchs");
            log.debug("{} 查询营销人员列表 用户中心返回值 jtBranchs = {}", findCode, jtBranchs);

            if (!"000000".equals(jtBranchs) && !"JT0000".equals(jtBranchs)) {//非全国

                List<String> branchCodes = new ArrayList<>();
                String[] branchs = jtBranchs.split(",");
                for (String b : branchs) {
                    branchCodes.add(b);
                    GenericListResponse<JtBranchInfoVo> result = userClient.queryThirdGradeBranch(b);
                    if (result.getTotal() > 0) {
                        List<String> third = result.getList().stream()
                                .map(JtBranchInfoVo::getCode)
                                .collect(Collectors.toList());
                        branchCodes.addAll(third);
                    }
                }
                criteria.andIn(MarketerInfoEntity::getBranchCode, branchCodes);

                log.info("{} 查询营销人员列表 分支机构包含->{}", findCode, JsonUtil.object2Json(branchCodes));
            }
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getChannelCode())) {
            criteria.andEqualTo(MarketerInfoEntity::getChannelCode, marketerInfoQO.getChannelCode());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getAddChannelCode())) {
            criteria.andEqualTo(MarketerInfoEntity::getAddChannelCode, marketerInfoQO.getAddChannelCode());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getReferrerCode())) {
            criteria.andEqualTo(MarketerInfoEntity::getReferrerCode, marketerInfoQO.getReferrerCode());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getReferrerName())) {
            criteria.andEqualTo(MarketerInfoEntity::getReferrerName, marketerInfoQO.getReferrerName());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getIsJoinTeam())) {
            criteria.andEqualTo(MarketerInfoEntity::getIsJoinTeam, marketerInfoQO.getIsJoinTeam());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getMarketerName())) {
            criteria.andEqualTo(MarketerInfoEntity::getMarketerName, marketerInfoQO.getMarketerName().trim());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getMarketerNo())) {
            criteria.andEqualTo(MarketerInfoEntity::getMarketerNo, marketerInfoQO.getMarketerNo().trim());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getMarketerPhone())) {
            criteria.andEqualTo(MarketerInfoEntity::getMarketerPhone, marketerInfoQO.getMarketerPhone().trim());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getBranchCode())) {
            criteria.andEqualTo(MarketerInfoEntity::getBranchCode, marketerInfoQO.getBranchCode());
        }

        if (StringUtils.isNotBlank(marketerInfoQO.getStatus())) {
            criteria.andEqualTo(MarketerInfoEntity::getStatus, marketerInfoQO.getStatus());
        }
        if (StringUtils.isNotBlank(marketerInfoQO.getRoleCode())) {
            criteria.andEqualTo(MarketerInfoEntity::getRoleCode, marketerInfoQO.getRoleCode());
        }
        weekend.setOrderByClause("create_time DESC");
        return weekend;
    }

    @Override
    public PageInfo<MarketerInfoEntity> queryMarketers(String findCode, MarketerInfoQO marketerInfoQO, boolean validationPermissions) {
        log.info("{} 查询营销人员列表 service 开始", findCode);
        Page page = PageHelper.startPage(marketerInfoQO.getPn(), marketerInfoQO.getPs());
        List<MarketerInfoEntity> entities = queryMarketerList(findCode, marketerInfoQO, validationPermissions);
        PageInfo info = new PageInfo(page);
        info.setList(entities);
        log.info("{} 查询营销人员列表 查询完成", findCode);
        return info;
    }


    @Override
    public List<MarketerInfoEntity> queryMarketerList(String findCode, MarketerInfoQO marketerInfoQO, boolean validationPermissions) {
        try {
            return marketerInfoMapper.selectByExample(
                    createWeekend(findCode, marketerInfoQO, validationPermissions));
        } catch (Exception e) {
            e.printStackTrace();
            log.info("{} 查询营销人员列表 异常 e->{}", findCode, e);
        }
        return Lists.newArrayList();
    }

    @Override
    public List<MarketerInfoEntity> exportMarketers(String findCode, MarketerInfoQO marketerInfoQO) {
        log.info("{} 导出营销人员列表 service 开始", findCode);
        List<MarketerInfoEntity> entities = null;
        try {
            entities = marketerInfoMapper.selectByExample(createWeekend(findCode, marketerInfoQO, true));
            log.info("{} 导出营销人员列表 查询完成", findCode);
        } catch (Exception e) {
            e.printStackTrace();
            log.info("{} 导出营销人员列表 异常 e->{}", findCode, e);
        }
        return entities;
    }

    @Override
    public void marketerEffect() {

        // 查询同步开始时间
        MarketerSyncTimeEntity time = marketerSyncTimeMapper.selectOne(null);

        String startDate = DateUtils.conver(time.getLastTime(), DateUtils.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS);
        String endDate = DateUtils.conver(new Date(), DateUtils.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS);

        // 分别同步各渠道营销人员信息
        marketerSync(MarketerChannelCodeEnum.TOUR_A01.getCode(), startDate, endDate);
        marketerSync(MarketerChannelCodeEnum.EDU_A02.getCode(), startDate, endDate);
        marketerSync(MarketerChannelCodeEnum.MED_A03.getCode(), startDate, endDate);
        marketerSync(MarketerChannelCodeEnum.FINANCE_A04.getCode(), startDate, endDate);
        marketerSync(MarketerChannelCodeEnum.SEQUIP_A05.getCode(), startDate, endDate);

        // 更新下次同步开始时间
        /**由于私保取的时间字段不是更新字段，是入职时间导致不能做增量所以不更新这个时间，采取全量更新
         time.setLastTime(DateUtils.str2Date(endDate, DateUtils.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS));
         marketerSyncTimeMapper.updateByPrimaryKey(time);
         */
    }

    private void marketerSync(String channelCode, String startDate, String endDate) {

        String findCode = "marketerEffect_" + System.currentTimeMillis();

        try {

            // 1.同步教育渠道营销人员
            BrokersInfoQO qo = new BrokersInfoQO();
            qo.setChannelcode(channelCode);
            qo.setAgentcode("");
            qo.setEnddate(endDate);
            qo.setStartdate(startDate);

            log.info("{} 同步增员账户信息 开始 调用销管入参 ->{}", findCode, JsonUtil.object2Json(qo));

            String response = jtsaleappClient.queryPrivateBrokers(qo);
            log.info("{} 同步增员账户信息 调用销管接口返回结果 result->{}", findCode, response);

            SaleResponseData resp = JsonUtils.fromJson(response, SaleResponseData.class);
            if (resp != null && resp.getRc() != null) {
                if ("0000".equals(resp.getRc())) {
                    if (resp.getData() != null) {
                        List<BrokersInfoVO> list = resp.getData();
                        if (list != null && list.size() > 0) {
                            list.forEach(v -> {
                                log.info("{} 同步增员账户信息 待同步账户信息 ->{}", findCode, JsonUtil.object2Json(v));
                                // 只接收有工号的账户信息
                                if (StringUtils.isNotBlank(v.getAgentcode())) {
                                    MarketerInfoEntity entity = new MarketerInfoEntity();
                                    entity.setMarketerNo(v.getAgentcode());
                                    entity.setMarketerName(v.getAgentname());
                                    entity.setMarketerPhone(v.getMobile());
                                    entity.setBranchCode(v.getBranchcode());
                                    entity.setBranchName(v.getBranchname());
                                    entity.setDepartCode(v.getDepartmentcode());
                                    entity.setDepartName(v.getDepartmentname());
                                    entity.setUpdateTime(DateUtils.getCurrentTime());
                                    //渠道编码有可能变更
                                    entity.setChannelCode(v.getChannelcode());
                                    entity.setChannelName(MarketerChannelCodeEnum.getMsgsByCodes(v.getChannelcode()));
                                    //todo 添加增员渠道  推荐人
                                    // 先查询该账户是否存在 存在->更新，不存在->插入
                                    Weekend<MarketerInfoEntity> weekend = Weekend.of(MarketerInfoEntity.class);
                                    WeekendCriteria<MarketerInfoEntity, Object> criteria = weekend.weekendCriteria();
                                    criteria.andEqualTo(MarketerInfoEntity::getMarketerNo, v.getAgentcode());
                                    criteria.andEqualTo(MarketerInfoEntity::getIsDeleted, false);
                                    List<MarketerInfoEntity> marketers = marketerInfoMapper.selectByExample(weekend);
                                    log.info("{} 同步增员账户信息 根据工号查询结果 ->{}", findCode, JsonUtil.object2Json(marketers));
                                    //判断之前是否有该员工信息
                                    if (marketers != null && marketers.size() > 0) {
                                        entity.setId(marketers.get(0).getId());
                                        // 该营销人员现在 包含教育渠道
                                        if (v.getChannelcode().contains(MarketerChannelCodeEnum.EDU_A02.getCode())) {
                                            log.info("{} 同步增员账户信息 该营销人员现在属于教育渠道", findCode);
                                            entity.setStatus(MarketerStatusEnum.STATUS_0.getCode());
                                            // 该营销人员之前不属于教育渠道 更新基本信息、认证状态、渠道编码、默认角色
                                            if (!marketers.get(0).getChannelCode().contains(MarketerChannelCodeEnum.EDU_A02.getCode())) {
                                                entity.setRoleCode(MarketerRoleEnum.ROLE_00.getCode());
                                                entity.setRoleName(MarketerRoleEnum.ROLE_00.getMsg());
                                                log.info("{} 同步增员账户信息 该营销人员之前不属于教育渠道 更新基本信息、认证状态、渠道编码、默认角色 包含信息->{}", findCode, JsonUtil.object2Json(entity));
                                            }
                                        } else {
                                            entity.setRoleName(MarketerRoleEnum.ROLE_00.getMsg());
                                            entity.setRoleCode(MarketerRoleEnum.ROLE_00.getCode());
                                            entity.setStatus(MarketerStatusEnum.STATUS_1.getCode());
                                            // 该营销人员存在 更新基本信息、渠道、认证状态为未认证、角色为默认自行营销人员
                                            log.info("{} 同步增员账户信息 该营销人员现在不属于教育渠道 且 已存在 更新以下信息->{}", findCode, JsonUtil.object2Json(entity));
                                        }
                                        marketerInfoMapper.updateByPrimaryKeySelective(entity);
                                    } else {
                                        // 该营销人员现在 包含教育渠道
                                        if (v.getChannelcode().contains(MarketerChannelCodeEnum.EDU_A02.getCode())) {
                                            entity.setStatus(MarketerStatusEnum.STATUS_0.getCode());
                                            log.info("{} 同步增员账户信息 该营销人员现在属于教育渠道", findCode);
                                        } else {
                                            entity.setStatus(MarketerStatusEnum.STATUS_1.getCode());
                                            log.info("{} 同步增员账户信息 该营销人员现在不属于教育渠道", findCode);
                                        }
                                        //初始化角色
                                        entity.setRoleName(MarketerRoleEnum.ROLE_00.getMsg());
                                        entity.setRoleCode(MarketerRoleEnum.ROLE_00.getCode());
                                        //用户编码
                                        entity.setUserCode(getUserCodeByLoginId(findCode, v.getMobile()));
                                        entity.setIsDeleted(false);
                                        //初始化小队信息
                                        entity.setIsJoinTeam(false);
                                        entity.setCreateTime(DateUtils.getCurrentTime());
                                        marketerInfoMapper.insertSelective(entity);
                                        log.info("{} 同步增员账户信息保存完成", findCode);
                                    }
                                } else {
                                    log.info("{} 同步增员账户信息 工号为空，不记录", findCode);
                                }
                            });
                        }
                    } else {
                        log.info("{} 同步增员账户信息 调用销管接口返回结果 result.getDate为空", findCode);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.info("{} 同步增员账户信息 异常->{}", findCode, e);
        }
    }

    private String getUserCodeByLoginId(String findCode, String loginId) {

        String userCode = "";

        log.info("{} 同步增员账户信息 根据手机号码查询userCode mobile->{}", findCode, loginId);

        GenericDataResponse<Map<String, String>> result = userClient.queryUserIsExist(loginId);

        log.info("{} 同步增员账户信息 调用用户中心查询userCode接口返回结果->{}", findCode, JsonUtil.object2Json(result));

        if (null != result && StringUtils.equals(result.getCode(), "0000")) {
            if (StringUtils.equals(result.getData().get("isExist"), "1")) {
                userCode = result.getData().get("userCode");
            }
        }

        log.info("{} 同步增员账户信息 mobile->{}, userCode->{}", findCode, loginId, userCode);

        return userCode;
    }


    @Override
    public ResponseEntity<GenericDataResponse<MarketerDetailBO>> queryMarketerDetails(String marketerNo) {
//        String findCode, MarketerInfoQO marketerInfoQO, boolean validationPermissions
        MarketerInfoQO marketerInfoQO = new MarketerInfoQO();
        marketerInfoQO.setMarketerNo(marketerNo);
        List<MarketerInfoEntity> marketerInfoEntities = queryMarketerList("", marketerInfoQO, false);
        if (CollectionUtils.isEmpty(marketerInfoEntities)) {
            return GenericDataResponse.errorWithMsg("无查询信息!", MarketerDetailBO.class);

        }
        //查询所有历史入队信息
        List<CommissionTeamVO> historyTeamVOS = teamService.queryTeamByMarketerNo(marketerNo, YesOrNoEnum.YES);
        return GenericDataResponse.okWithData(new MarketerDetailBO(marketerInfoEntities.get(0), historyTeamVOS));
    }


}
